var getRequest = function (url, callback) {
    fetch(url)
        .then(response => response.json())
        .then((json) => {
            callback(json);
        })
        .catch(e => {
            console.log('============== network error =================');
            console.log(e);
            console.log('====================================');
        })
};


var postRequest = function (url, params, callback) {
    var myInit = {
        method: "POST",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        body: JSON.stringify(params)
    }

    fetch(url, myInit)
        .then(function (res) {
            // if (res.ok) {
            //     console.log("Perfect! Your settings are saved.");
            // } else if (res.status == 401) {
            //     console.log("Oops! You are not authorized.");
            // }
        })
        .catch(e => {
            console.log('============== network error =================');
            console.log(e);
            console.log('====================================');
        });


};



export {
    getRequest,
    postRequest
};

